//加载用户仓库数据----------------------------------------------------------------------
var current_player_farm_warehouse_detail;
function gamePlayerFarmWarehouseDetail(page) {
	$.ajax({
		type:"POST",
		url: ajaxUrl + "/game/1.0/sfg/player/warehouse.js?jobId="+getTimeMs(),
		data:{
			token : window.localStorage.getItem('token'),
			sid: currentSID,
			gameId: 'SFG'
		},
		dataType:"JSON",
		success:function(request){
			console.log(request);
			if (request.code != 0) {
				doErrorMessage(request.code, request.msg);
			} else {	
				//数据整理为散列表
				current_player_farm_warehouse_detail = new HashTable(); 
				for(let x = 0 ; x < request.data.length ; x++){
					current_player_farm_warehouse_detail.put('warehouse_'+x, request.data[x]);
				}
				showPlayerWarehouseDetail();
			}
		},
		error:function(error){
			console.log(error);	
		}
	});		
}
//构建仓库、口袋、好友、商店
function showPlayerWarehouseDetail(){
	$('#player_game_interact_title').html('仓库');
	//初始化
	let dom = $('#player_game_interact_action_div');
	dom.html('');
	let str = '';
	//区域蒙版
	//console.log(current_player_farm_warehouse_detail);
	for(let x = 0 ; x < 30 ; x ++){
		//console.log('land_==='+(x+1));
		let warehouse = current_player_farm_warehouse_detail.get('warehouse_'+x);
		//console.log('warehouse==='+warehouse);
		if(checkEmpty(warehouse)){//判断是否有效
			break;
		}
		str =  str + '<div class="commonbox" onclick="playerWarehouseOperate('+x+')">';
		str =  str + '<span class=" cdf">'+warehouse.propName+'</span><br>';
		str =  str + '<span class="">'+warehouse.propNum+'</span>';
		str =  str + '</div>';
	}
	//console.log(str);
	dom.append(str);
}
////////////////////////////////////////////////////////////////////////////////
//加载用户口袋数据----------------------------------------------------------------------
var current_player_farm_pocket_detail;
function gamePlayerFarmPocketDetail(page) {
	$.ajax({
		type:"POST",
		url: ajaxUrl + "/game/1.0/sfg/player/pocket.js?jobId="+getTimeMs(),
		data:{
			token : window.localStorage.getItem('token'),
			sid: currentSID,
			gameId: 'SFG',
			page: page
		},
		dataType:"JSON",
		success:function(request){
			console.log(request);
			if (request.code != 0) {
				doErrorMessage(request.code, request.msg);
			} else {	
				//数据整理为散列表
				current_player_farm_pocket_detail = new HashTable(); 
				for(let x = 0 ; x < request.data.length ; x++){
					current_player_farm_pocket_detail.put('pocket_'+x, request.data[x]);
				}
				showPlayerPocketDetail();
			}
		},
		error:function(error){
			console.log(error);	
		}
	});		
}
//构建仓库、口袋、好友、商店
function showPlayerPocketDetail(){
	$('#player_game_interact_title').html('口袋');
	//初始化
	let dom = $('#player_game_interact_action_div');
	dom.html('');
	let str = '';
	//区域蒙版
	//console.log(current_player_farm_warehouse_detail);
	for(let x = 0 ; x < 30 ; x ++){
		//console.log('land_==='+(x+1));
		let pocket = current_player_farm_pocket_detail.get('pocket_'+x);
		//console.log('pocket==='+pocket);
		if(checkEmpty(pocket)){//判断是否有效
			break;
		}
		//landState(1未开垦2未种植3未翻地)
		str =  str + '<div class="commonbox" onclick="playerPocketOperate('+x+')">';
		str =  str + '<span class=" cdf">'+pocket.propName+'</span><br>';
		str =  str + '<span class="">'+pocket.propNum+'</span>';
		str =  str + '</div>';
	}
	//console.log(str);
	dom.append(str);
}
//加载用户好友数据----------------------------------------------------------------------
var current_player_friend_detail;
function gamePlayerFriendDetail(page) {
	$.ajax({
		type:"POST",
		url: ajaxUrl + "/game/1.0/sfg/player/friend.js?jobId="+getTimeMs(),
		data:{
			token : window.localStorage.getItem('token'),
			sid: currentSID,
			gameId: 'SFG'
		},
		dataType:"JSON",
		success:function(request){
			console.log(request);
			if (request.code != 0) {
				doErrorMessage(request.code, request.msg);
			} else {		
				//数据整理为散列表
				current_player_friend_detail = new HashTable(); 
				for(let x = 0 ; x < request.data.length ; x++){
					current_player_friend_detail.put('friend_'+x, request.data[x]);
				}
			}
		},
		error:function(error){
			console.log(error);	
		}
	});		
}
function showPlayerFriendDetail(){
	$('#player_game_interact_title').html('好友');
	//初始化
	let dom = $('#player_game_interact_action_div');
	dom.html('');
	let str = '';
	//区域蒙版
	//console.log(current_player_friend_detail);
	for(let x = 0 ; x < 30 ; x ++){
		//console.log('land_==='+(x+1));
		let friend = current_player_friend_detail.get('friend_'+x);
		//console.log('friend==='+friend);
		if(checkEmpty(friend)){//判断是否有效
			break;
		}
		//landState(1未开垦2未种植3未翻地)
		str =  str + '<div class="commonbox" onclick="playerFriendOperate('+x+')">';
		str =  str + '<span class=" cdf">'+friend.propName+'</span><br>';
		str =  str + '<span class="">'+friend.propNum+'</span>';
		str =  str + '</div>';
	}
	//console.log(str);
	dom.append(str);
}
//加载系统商店数据----------------------------------------------------------------------
var current_game_store_detail;
function gameStoreDetail(page) {
	$.ajax({
		type:"POST",
		url: ajaxUrl + "/game/1.0/sfg/player/store.js?jobId="+getTimeMs(),
		data:{
			token : window.localStorage.getItem('token'),
			sid: currentSID,
			gameId: 'SFG'
		},
		dataType:"JSON",
		success:function(request){
			console.log(request);
			if (request.code != 0) {
				doErrorMessage(request.code, request.msg);
			} else {	
				//数据整理为散列表
				current_game_store_detail = new HashTable(); 
				for(let x = 0 ; x < request.data.length ; x++){
					current_game_store_detail.put('store_'+x, request.data[x]);
				}
				showGameStoreDetail();
			}
		},
		error:function(error){
			console.log(error);	
		}
	});		
}

function showGameStoreDetail(){
	$('#player_game_interact_title').html('商店');
	//初始化
	let dom = $('#player_game_interact_action_div');
	dom.html('');
	let str = '';
	//区域蒙版
	//console.log(current_game_store_detail);
	for(let x = 0 ; x < 30 ; x ++){
		//console.log('land_==='+(x+1));
		let store = current_game_store_detail.get('store_'+x);
		//console.log('store==='+store);
		if(checkEmpty(store)){//判断是否有效
			break;
		}
		//landState(1未开垦2未种植3未翻地)
		str =  str + '<div class="commonbox" onclick="playerStoreOperate('+x+')">';
		str =  str + '<span class=" cdf">'+store.waresName+'</span><br>';
		str =  str + '<span class="">'+store.waresPrice+'</span>';
		str =  str + '</div>';
	}
	//console.log(str);
	dom.append(str);
}
